<template>
  <div class="matters-attention">
    <div class="shade"></div>
    <div class="popup">
      <div class="title justify-content-between">
        <span class="fs28 colorFFF">注意事项</span>
        <img src="../assets/images/icon-close.png" @click="cancel()" />
      </div>
      <div class="content">
        <textarea v-model="careful" placeholder="请输入注意事项"></textarea>
      </div>
      <div class="btns justify-content-center">
        <div class="btn sure" @click="save()" v-loading="loading">确认</div>
        <div class="btn cancel" @click="cancel()">取消</div>
      </div>
    </div>
  </div>
</template>

<script>
import api from '@/api/taskApi.js';
export default {
  name: "MattersAttention",
  props: {
    info: Object,
    modelType:"",
  },
  data() {
    return {
      loading: false,
      careful:"",
    };
  },
  created(){
    this.getData()
    
  },
  methods: {
    // 关闭弹窗
    cancel() {
      this.$emit("cancel");
    },
    // 保存注意事项
    save() {
      let params={
        "careful": this.careful,
        "taskId": this.$route.query.taskId,
        "modelType":this.modelType,
      }
      api.TaskModuleSaveApi(params).then(res=>{
        if(+res.data.code==200){
          this.$message.success('保存成功')
          this.$emit("cancel");
        }else{
           this.$message.error('保存失败')
        }
      })
    },
    // 查询数据
    getData(){
      let params={
        "modelType": this.modelType,
        "taskId": this.$route.query.taskId
      }
      api.getTaskModuleOptApi(params).then(res=>{
        if(+res.data.code==200){
          this.careful=res.data.data.careful;
        }else{
           this.$message.error('保存失败')
        }
      })
    }
  },
};
</script>

<style scoped lang='less'>
.matters-attention {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  .shade {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
  }
  .popup {
    width: 10.3rem;
    height: 5.81rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    box-shadow: 0 0.05rem 0.15rem 0 rgba(0, 21, 54, 0.25);
    .title {
      width: 100%;
      height: 0.58rem;
      background-color: #285fe3;
      padding: 0 0.23rem 0 0.4rem;
      img {
        width: 0.23rem;
        height: 0.23rem;
        cursor: pointer;
      }
    }
    .content {
      width: 100%;
      margin-top: .44rem;
      padding: 0 0.38rem;
      textarea {
        width: 100%;
        height: 3.48rem;
        border: 1px solid #aab3c4;
        font-size: 0.2rem;
        color: #505971;
        padding: 0.16rem;
        resize: none;
        font-weight: 400;
        font-family: "Microsoft YaHei,Arial";
      }
      textarea::placeholder {
        color: #aab3c4;
      }
      textarea:focus {
        outline: 1px solid #316eff;
        color: #161d2e;
      }
    }
    .btns {
      width: 100%;
      margin-top: 0.18rem;
      .btn {
        width: 1.3rem;
        height: 0.4rem;
        margin-left: 1.12rem;
        line-height: 0.4rem;
        text-align: center;
        border-radius: 0.03rem;
        font-size: 0.22rem;
        cursor: pointer;
      }
      .btn.sure {
        background: linear-gradient(0deg, #00a366 0%, #00c37a 100%);
        color: #fff;
      }
      .btn.cancel {
        border: 1px solid #316eff;
        background: linear-gradient(0deg, #d9dde8 0%, #ffffff 100%);
        color: #505971;
      }
      .btn:first-child {
        margin-left: 0;
      }
    }
  }
}
</style>